﻿#region Includes

using System.Text;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Configuration;

#endregion

namespace ArtheaEngine.Model
{
    public partial class Player : Character
    {
        public Player()
        {
        }

        public override void Save()
        {
            World.Context.SaveChanges();
        }

        public override World World
        {
            get { return Account.Connection.World; }
        }

        public bool HasReadNote(Note note)
        {
            var last = LastNotes.SingleOrDefault(b => b.Board == note.Board);

            if (last == null) return false;

            return note.When < last.LastNote;
        }

        #region Overrides of Character

        public override void Dispose()
        {
            base.Dispose();
        }

        public override void Page(StringBuilder buf)
        {
            if (Account != null)
                Account.Page(buf);
        }

        public override void Write(string format, params object[] args)
        {
            if (Account != null)
            {
                Account.Write(format, args);
            }
        }

        public override void Write(byte[] value)
        {
            if (Account == null) return;

            Account.Write(value);
        }

        public override void Write(object obj)
        {
            if (Account == null) return;

            Account.Write(obj);
        }

        public override void WriteLine()
        {
            if (Account == null) return;

            Account.WriteLine();
        }

        public override void WriteLine(object obj)
        {
            if (Account == null) return;

            Account.WriteLine(obj);
        }

        public override void WriteLine(string format, params object[] args)
        {
            if (Account == null) return;

            Account.WriteLine(format, args);
        }

        #endregion

    }
}